import type { RemoveMethods } from "@/types/remove-methods";
import { TaskBoardList } from "@model/TaskBoardList";

export class SurfaceSetting {
  maxId: number;
  fieldExpandedNames: Array<string>;
  LifeModelListKey: string | number;
  LifeModelItemsKey: string | number;
  FieldTreeKey: string | number;
  GoalListKey: string | number;
  StageState: string;
  showGoal: number;
  StageListKey: string | number;
  showLifeModel: number;
  showField: Array<string | number>;
  menuKey: string;
  StageLastStartTimeInterval: number; // 阶段计算时间的间隔

  TaskListKey: number;
  showStage: Array<number>;
  taskState4Task: string;
  taskState4Clock: string;

  taskBoardList: TaskBoardList;

  OperationPanelExpandedNames: Array<string>;
  TaskBoardPanelExpandedNames: Array<string>;
  toRemoveMediaPath: Array<string>;

  memoryChooseTaskResults: Array<number>;
  memoryChooseLifeResults: Array<number>;
  memoryPanelKey: number;

  statChooseTaskResults: Array<number>;
  statChooseLifeResults: Array<number>;
  statChooseTimeRange: string;

  carouselImg: Array<string>;

  getTaskBoardDataById(id: number) {
    return this.taskBoardList.taskBoardList[id];
  }

  getTaskState(type: number) {
    if (type === 1) return this.taskState4Task;
    if (type === 2) return this.taskState4Clock;
    return "";
  }
  setTaskState(type: number, state: string) {
    if (type === 1) this.taskState4Task = state;
    if (type === 2) this.taskState4Clock = state;
  }

  constructor(data: RemoveMethods<SurfaceSetting>) {
    Object.assign(this, data);
  }
  setInfo(data: RemoveMethods<SurfaceSetting>) {
    Object.assign(this, data);
  }
  getShowField() {
    return parseInt(this.showField[0].toString());
  }
  getShowStage() {
    return this.showStage[0];
  }
  deleteTaskBoardData(index: number) {
    this.taskBoardList.taskBoardList = this.taskBoardList.taskBoardList.filter(
      (value, i) => value !== undefined && i !== index,
    );
    this.taskBoardList.changeKey = new Date().getTime();
  }
}
